const http = require('http')

const server = http.createServer((req, res) => {
  console.log('请求进行来了')

  // post
  let arr = []
  req.on('data', (data) => {
    arr.push(data)
  })
  req.on('end', () => {
    let obj = Buffer.concat(arr).toString()
      res.end("服务端返回的数据")
    // if (req.headers['content-type'] == 'application/json') {
    //   let a = JSON.parse(obj)
      
    //   a.add = '互联网人的大学'
    //   console.log(a);
    //   res.end(JSON.stringify(a))
    // }else if(req.headers['content-type'] == 'application/x-www-form-urlencoded') {
    //   let ret = querystring.parse(obj)
    //   console.log(ret);
    //   ret.c= 3
    //   res.end(JSON.stringify(ret))
    // }
  })
})
server.listen(1234, () => {
  console.log('web服务端启动了')
})